﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace DatabaseTools
{
    public class Tools
    {
        public static void Serialize(string path, Database db)
        {
            Stream stream = File.Open(path, FileMode.Create);
            BinaryFormatter bformatter = new BinaryFormatter();
            bformatter.Serialize(stream, db);
            stream.Close();
        }

        public static Database DeSerialize(string path)
        {
            Stream stream = File.Open(path, FileMode.Open);
            BinaryFormatter bformatter = new BinaryFormatter();
            Database db = (Database)bformatter.Deserialize(stream);
            stream.Close();
            return db;
        }
    }
}
